package com.nbsaas.boot.ai.data.entity;

import com.nbsaas.boot.code.annotation.FormAnnotation;
import com.nbsaas.boot.code.annotation.FormField;
import com.nbsaas.boot.code.annotation.data.Dict;
import com.nbsaas.boot.code.annotation.data.DictItem;
import com.nbsaas.boot.jpa.data.entity.AbstractEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Lob;
import jakarta.persistence.Table;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.Comment;

import java.math.BigDecimal;

@Comment("智能体配置")
@FormAnnotation(model = "智能体配置")
@Data
@EqualsAndHashCode(callSuper = true)
@Entity
@Table(name = "nb_ai_agent_config")
public class AiAgentConfig extends AbstractEntity {

    @Comment("智能体名称")
    @FormField(title = "名称", placeholder = "请输入智能体名称", grid = true)
    @Column(length = 100, nullable = false)
    private String name;

    @Comment("智能体唯一编码")
    @FormField(title = "编码", placeholder = "请输入唯一编码", grid = true)
    @Column(length = 64, unique = true, nullable = false)
    private String code;

    @Comment("模型服务提供方")
    @FormField(title = "服务商", placeholder = "例如 OpenAI", grid = true)
    @Column(length = 50)
    private String provider;

    @Comment("使用模型")
    @FormField(title = "模型", placeholder = "请输入模型标识", grid = true)
    @Column(length = 100)
    private String model;

    @Comment("温度参数")
    @FormField(title = "温度", placeholder = "0.0 - 2.0")
    @Column(precision = 4, scale = 2)
    private BigDecimal temperature;

    @Comment("TopP采样参数")
    @FormField(title = "TopP", placeholder = "0.0 - 1.0")
    @Column(precision = 4, scale = 2)
    private BigDecimal topP;

    @Comment("最大Tokens")
    @FormField(title = "最大Tokens")
    private Integer maxTokens;

    @Comment("频率惩罚")
    @FormField(title = "频率惩罚", placeholder = "0.0 - 2.0")
    @Column(precision = 4, scale = 2)
    private BigDecimal frequencyPenalty;

    @Comment("存在惩罚")
    @FormField(title = "存在惩罚", placeholder = "0.0 - 2.0")
    @Column(precision = 4, scale = 2)
    private BigDecimal presencePenalty;

    @Comment("系统提示词")
    @FormField(title = "系统提示词", placeholder = "请输入系统提示")
    @Lob
    private String systemPrompt;

    @Comment("功能描述")
    @FormField(title = "功能描述", placeholder = "请输入功能描述")
    @Column(length = 500)
    private String description;

    @Comment("工具配置")
    @FormField(title = "工具配置", placeholder = "JSON 配置")
    @Column(length = 2000)
    private String toolConfig;

    @Dict(
            items = {
                    @DictItem(value = 1, label = "启用"),
                    @DictItem(value = -1, label = "禁用")
            }
    )
    @Comment("是否启用")
    @FormField(title = "启用状态", grid = true)
    private Integer enabled;

    @Comment("排序权重")
    @FormField(title = "排序权重", grid = true)
    private Integer sort;

    @Comment("备注信息")
    @FormField(title = "备注", placeholder = "请输入备注信息")
    private String note;
}


